package com.tencent.mm.ui.tools;

import android.animation.Animator;
import android.animation.TimeInterpolator;
import android.annotation.TargetApi;
import android.view.View;
import android.view.animation.AnimationUtils;

import com.tencent.mm.R;
import com.tencent.mm.compatible.util.UtilD;

public class ToolsJ {
    public interface a {
        void aTY();

        void onAnimationEnd();
    }

    @TargetApi(14)
    public static final void w(View view, float f) {
        if (view == null || UtilD.kX(14)) {
            return;
        }
        Animator animator = (Animator) view.getTag(2131303255);
        if (animator != null) {
            animator.cancel();
        }
        view.animate().cancel();
        view.setTranslationX(f);
        view.setTranslationY(0.0f);
    }

    @TargetApi(14)
    public static final void a(View view, long j, float f, final a aVar) {
        if (view == null || UtilD.kX(14)) {
            return;
        }
        Animator animator = (Animator) view.getTag(2131303255);
        if (animator != null) {
            animator.cancel();
        }
        view.animate().cancel();
        view.animate().setListener(null);
        TimeInterpolator loadInterpolator = AnimationUtils.loadInterpolator(view.getContext(), R.anim.c0);
        if (aVar == null) {
            view.animate().setDuration(j).translationX(f).translationY(0.0f).setInterpolator(loadInterpolator);
            return;
        }
        view.animate().setDuration(j).translationX(f).translationY(0.0f).setInterpolator(loadInterpolator).setListener(new Animator.AnimatorListener() {
            public final void onAnimationStart(Animator animator) {
            }

            public final void onAnimationRepeat(Animator animator) {
            }

            public final void onAnimationEnd(Animator animator) {
                aVar.onAnimationEnd();
            }

            public final void onAnimationCancel(Animator animator) {
                aVar.aTY();
            }
        });
    }
}
